﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.IO;
using System.Net.Http.Headers;

namespace HCQ2WebAPI_Logic.Model
{
    /// <summary>
    ///  处理文件名称自动生成
    /// </summary>
    public class CustomMultipartFormDataStreamProvider: MultipartFormDataStreamProvider
    {
        public CustomMultipartFormDataStreamProvider(string path) : base(path) { }
        public override string GetLocalFileName(HttpContentHeaders headers)
        {
            //修改文件名称并返回
            string newFileName = string.Empty;
            newFileName = Path.GetExtension(headers.ContentDisposition.FileName.Replace("\"", string.Empty));//获取后缀名
            newFileName = Guid.NewGuid().ToString().Replace("-", "") + newFileName;
            return newFileName;
        }
    }
}
